$(function() {
	//出生日期的显示和隐藏
	$(".birth").click(function() {
		$(".datepicker-year-work").hide();
		$(".datepicker-month-birth").hide();
		$(".datepicker-month-work").hide();
		$(".datepicker-year-birth").slideToggle();
	});
	//选择出生的年份
	$(".picker-content-birth ").on("click","span[class='cell year']",function() {
		var a = $(this).text();
		$(this).attr("class", "cell year selected").siblings().attr("class", "cell year");
		$(".datepicker-year-birth").hide();
		$(".datepicker-month-birth").show();
		$(".month-year-btn").text(a+"年");
		//选择出生的月份
		$(".picker-content-month").on("click","span[class='cell month']",function() {
			var b = $(this).text();
			$(this).attr("class", "cell month selected").siblings().attr("class", "cell month");
			$(".datepicker-year-birth").hide();
			$(".datepicker-month-birth").hide();
			//月份转换
			if(b == '一月') {
				b = '01';
			} else if(b == '二月') {
				b = '2';
			} else if(b == '三月') {
				b = '03';
			} else if(b == '四月') {
				b = '04';
			} else if(b == '五月') {
				b = '05';
			} else if(b == '六月') {
				b = '06';
			} else if(b == '七月') {
				b = '07';
			} else if(b == '八月') {
				b = '08';
			} else if(b == '九月') {
				b = '09';
			} else if(b == '十月') {
				b = '10';
			} else if(b == '十一月') {
				b = '11';
			} else if(b == '十二月') {
				b = '12';
			}
			var ym = a + '-' + b;
			$(".birth").val(ym);
		});
	});
	//切换更大出生年份
	$(".prev").on("click", function() {
		var startyear = parseInt($(this).next().text().trim().substring(0, 4).trim());
		var endyear = parseInt($(this).next().text().trim().substring(7, 11).trim());
		startyear = startyear - 10;
		endyear = endyear - 10;
		$(".picker-header-birth").children("span").eq(1).text(startyear + " - " + endyear + "年");
		$(".picker-content-birth").text("");
		for(var i = startyear; i <= endyear; i++) {
			var $span = $('<span class=>' + i + '</span>');
			$span.attr("class", "cell year")
			$(".picker-content-birth").append($span);
		};
	});
	//切换更小出生年份
	$(".next").on("click",function() {
		var startyear = parseInt($(this).prev().text().trim().substring(0, 4).trim());
		var endyear = parseInt($(this).prev().text().trim().substring(7, 11).trim());
		startyear += 10;
		endyear += 10;
		$(".picker-header-birth").find("span").eq(1).text(startyear + " - " + endyear + "年");
		$(".picker-content-birth").text("");
		for(var i = startyear; i <= endyear; i++) {
			var $span = $('<span class=>' + i + '</span>');
			$span.attr("class", "cell year")
			$(".picker-content-birth").append($span);
		}
	});
	//工作时间的显示和隐藏
	$(".work").click(function() {
		$(".datepicker-year-birth").hide();
		$(".datepicker-month-work").hide();
		$(".datepicker-month-birth").hide();
		$(".datepicker-year-work").slideToggle();
	});
	$(".picker-content-work span[class='cell year no-exp']").on("click",function() {
			var c = $(this).text();
			$(this).attr("class", "cell year selected no-exp").siblings().attr("class", "cell year no-exp");
			$(".datepicker-year-work").hide();
			$(".picker-content-month-work").hide();
			$(".work").attr("value", c);
		});
	//选择工作时间的年份
	$(".picker-content-work").on("click","span[class='cell year']",function() {
		var a = $(this).text();
		$(this).attr("class", "cell year selected").siblings().attr("class", "cell year");
		$(".datepicker-year-work").hide();
		$(".datepicker-month-work").show();
		$(".month-year-btn").text(a+"年");
		//选择工作时间的月份
		$(".picker-content-month-work").on("click","span[class='cell month']",function() {
			var b = $(this).text();
			$(this).attr("class", "cell month selected").siblings().attr("class", "cell month");
			$(".datepicker-year-work").hide();
			$(".datepicker-month-work").hide();
			if(b == '一月') {
				b = '01';
			} else if(b == '二月') {
				b = '2';
			} else if(b == '三月') {
				b = '03';
			} else if(b == '四月') {
				b = '04';
			} else if(b == '五月') {
				b = '05';
			} else if(b == '六月') {
				b = '06';
			} else if(b == '七月') {
				b = '07';
			} else if(b == '八月') {
				b = '08';
			} else if(b == '九月') {
				b = '09';
			} else if(b == '十月') {
				b = '10';
			} else if(b == '十一月') {
				b = '11';
			} else if(b == '十二月') {
				b = '12';
			}
			var ym = a + '-' + b;
			$(".work").attr("value", ym);
		});
	});
	//切换工作时间的更大年份
	$(".prev").on("click", function() {
		var startyear = parseInt($(this).next().text().trim().substring(0, 4).trim());
//		var endyear = parseInt($(this).next().text().trim().substring(7, 11).trim());
		startyear = startyear + 11;
		var endyear = startyear + 11;
		$(".picker-header-work").children("span").eq(1).text(endyear + " - " + '无工作经验');
		$(".picker-content-work").text("");
		for(var i = startyear; i <= endyear;) {
			if(i == 2008){
				var j = "无工作经验";
				var $span = $('<span class=>' + j + '</span>');
				$span.attr("class", "cell year no-exp");
				$(".picker-content-work").append($span);
			}
			i++;
			var $span1 = $('<span class=>' + i + '</span>');
			$span1.attr("class", "cell year");
			$(".picker-content-work").append($span1);
		}
	});
	//切换工作时间更小年份
	$(".next").on("click",function() {
		$(".prev").show();
		var startyear = parseInt($(this).prev().text().trim().substring(0, 4).trim());
//		var endyear = parseInt($(this).prev().text().trim().substring(7, 11).trim());
		startyear -= 11;
		var endyear = startyear - 11;
		$(".picker-header-work").find("span").eq(1).text(endyear + " - " + startyear);
		$(".picker-content-work").text("");
		for(var i = startyear; i >= endyear; i--) {
			var $span = $('<span class=>' + i + '</span>');
			$span.attr("class", "cell year");
			$(".picker-content-work").append($span);
		}
	});
	var work = $(".work").val();
	if(work == ""){
		$(".radio-group-rectangle-state1").show();
	}else if(work != ""){
		$(".radio-group-rectangle-state1").hide();
		$(".radio-group-rectangle-state").show();
	};
	$(".picker-content-work span[class='cell year no-exp']").click(function(){
		$(".radio-group-rectangle-state").hide();
		$(".radio-group-rectangle-state1").show();
	});
	$(".picker-content-work span[class='cell year']").click(function(){
		$(".radio-group-rectangle-state1").hide();
		$(".radio-group-rectangle-state").show();
	});
//	$("body").click(function(){
//		$(".datepicker-year-birth").hide();
//		$(".datepicker-month-birth").hide();
//		$(".datepicker-year-work").hide();
//		$(".datepicker-month-work").hide();
//	});
	//当前求职状态的鼠标单击事件
	//离职-随时到岗
	$("[ka='applystatus-3']").on("click",function(){
		$("[ka='applystatus-3']").css({"border-color":"#18c3b1","background-color":"#effbfa"});
		$("[ka='applystatus-0']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
		$("[ka='applystatus-1']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
		$("[ka='applystatus-2']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
	});
	//在职-月内到岗
	$("[ka='applystatus-2']").click(function(){
		$("[ka='applystatus-2']").css({"border-color":"#18c3b1","background-color":"#effbfa"});
		$("[ka='applystatus-0']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
		$("[ka='applystatus-1']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
		$("[ka='applystatus-3']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
	});
	//在职-考虑机会
	$("[ka='applystatus-1']").click(function(){
		$("[ka='applystatus-1']").css({"border-color":"#18c3b1","background-color":"#effbfa"});
		$("[ka='applystatus-0']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
		$("[ka='applystatus-3']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
		$("[ka='applystatus-2']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
	});
	//在职-暂不考虑
	$("[ka='applystatus-0']").click(function(){
		$("[ka='applystatus-0']").css({"border-color":"#18c3b1","background-color":"#effbfa"});
		$("[ka='applystatus-3']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
		$("[ka='applystatus-1']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
		$("[ka='applystatus-2']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
	});
	//在校生-找实习
	$("[ka='freshgraduate-2']").click(function(){
		$("[ka='freshgraduate-2']").css({"border-color":"#18c3b1","background-color":"#effbfa"});
		$("[ka='freshgraduate-1']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
	});
	//应届生-找工作
	$("[ka='freshgraduate-1']").click(function(){
		$("[ka='freshgraduate-1']").css({"border-color":"#18c3b1","background-color":"#effbfa"});
		$("[ka='freshgraduate-2']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
	});
	
	$("[ka='gender-1']").click(function(){
		$("[ka='gender-1']").css({"border-color":"#18c3b1","background-color":"#effbfa"});
		$("[ka='gender-0']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
	});
	//性别的单击事件
	$("[ka='gender-0']").click(function(){
		$("[ka='gender-0']").css({"border-color":"#18c3b1","background-color":"#effbfa"});
		$("[ka='gender-1']").css({"background-color":"#fff","border":"1px solid #e3e7ed"});
	});
	//判断姓名是否为空
	$(".btn-primary").click(function(){
		var name = $(".user-name").val();
		if (name == "") {
			$(".item-content-name").append("<div class='form-error-tip'>请输入姓名</div>");
		}if(name != ""){
    		$(".item-content-name>div[class='form-error-tip']").remove();
    	}
	});
	//判断出生日期是否为空
	 $(".btn-primary").click(function(){
    	var birth = $(".birth").val();
    	if(birth == ""){
    		$(".item-content-birth").append("<div class='form-error-tip'>请输入出生日期</div>");
    	}else if(wrap != ""){
    		$(".item-content-birth>div[class='form-error-tip']").remove();
    	}
    });
    //判断工作日期是否为空
    $(".btn-primary").click(function(){
    	var work = $(".work").val();
    	if(work== ""){
    		$(".item-content-work").append("<div class='form-error-tip'>请输入工作日期</div>");
    	}else if(wrap != ""){
    		$(".item-content-work>div[class='form-error-tip']").remove();
    	}
    });
	$(".btn-primary").click(function(){
		var name = $(".user-name").val();
		var birth = $(".birth").val();
		var work = $(".work").val();
		if(name != "" && birth != "" && work != ""){
			window.location.href="../10-10/index.html";
		}
	});
	//点击显示和隐藏切换头像的页面
	$(".name-photo").click(function(){
		$(".select-photo-dialog").slideToggle();
		$(".dialog-container").slideToggle();
	});
	//点击隐藏切换头像的页面
	$("[ka='dialog_layer']").click(function(){
		$(".select-photo-dialog").hide();
		$(".dialog-container").hide();
		$(".guide-create-resume-dialog").hide();
	});
	//点击X隐藏切换头像的页面
	$("[ka='dialog_close']").click(function(){
		$(".select-photo-dialog").hide();
		$(".dialog-container").hide();
		$(".guide-create-resume-dialog").hide();
	});
	//点击切换头像
	$(".avatars").on("click","li[class='avatar']",function(){
		$(this).attr("class", "avatar selected").siblings().attr("class", "avatar");
	});
	//选择图片切换头像
	$("li[class='avatar'] img").click(function(){
		var avatar = $(this).attr("src");
		$(".btn-sure").click(function(){
			$("[ka='upload-avatar'] img").attr("src",avatar);
			$(".select-photo-dialog").hide();
			$(".dialog-container").hide();
		});
	});
	
	
	$("[ka='switch_recruit1']").click(function(){
		$(".guide-create-resume-dialog").show();
		$(".dialog-container").show();
	});
	$("[ka='dialog_cancel']").click(function(){
		$(".guide-create-resume-dialog").show();
		$(".dialog-container").show();
	});
//	$("[ka='dialog_sure']").click(function(){
//		location.href = "file:"
//	});
	function browseFolder(path) {
    try {
        var Message = "\u8bf7\u9009\u62e9\u6587\u4ef6\u5939"; //选择框提示信息
        var Shell = new ActiveXObject("Shell.Application");
        var Folder = Shell.BrowseForFolder(0, Message, 64, 17); //起始目录为：我的电脑
        //var Folder = Shell.BrowseForFolder(0, Message, 0); //起始目录为：桌面
        if (Folder != null) {
            Folder = Folder.items(); // 返回 FolderItems 对象
            Folder = Folder.item(); // 返回 Folderitem 对象
            Folder = Folder.Path; // 返回路径
            if (Folder.charAt(Folder.length - 1) != "\\") {
                Folder = Folder + "\\";
            }
            document.getElementById(path).value = Folder;
            return Folder;
        }
    }
    catch (e) {
        alert(e.message);
    }
	}
})
